{include file="public/header" /}
<link rel="stylesheet" href="/static/admin/builder/css/base.css" media="all">
<style>
    .layui-form-item {
        margin-bottom: 15px !important;
        clear: both;
        *zoom: 1;
    }
</style>
<body>
<div class="layui-fluid layui-anim layui-anim-downbit">
    <div class="layui-card">
        <div class="layui-card-body" style="padding: 15px;">
            <form action="{:url('save')}" class="layui-form" id="form">
                <div class="layui-form-item">
                    <label class="layui-form-label">上次发放时间 </label>
                    <div class="layui-input-block">
                        <input type="text" autocomplete="off" class="layui-input" placeholder="暂无"
                               value="{$last?$last.create_time:''}" readonly/>
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">本次新增业绩 </label>
                    <div class="layui-input-block">
                        <input type="text" autocomplete="off" class="layui-input" placeholder="暂无" value="{$total}"
                               readonly/>
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">当前联合分红</label>
                    <div class="layui-input-inline">
                        <input type="text" class="layui-input" readonly
                               value="{:cache('system')['joint_bonus_tp'] * 100}%"/>
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">分红总金额</label>
                    <div class="layui-input-inline">
                        <input type="text" class="layui-input" readonly
                               value="{:round($total * (cache('system')['joint_bonus_tp']),2)}"/>
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">联合创始人</label>
                    <div class="layui-input-inline">
                        <input type="text" class="layui-input" readonly value="{:count($people)}"/>
                    </div>
                    <div class="layui-form-mid layui-word-aux">人</div>
                </div>
                <div class="layui-form-item">

                    <label class="layui-form-label">当前平均分配</label>
                    <div class="layui-input-inline">
                        <input type="text" class="layui-input" readonly
                               value="{:cache('system')['joint_bonus_tp_1'] * 100}"/>
                    </div>
                    <div class="layui-form-mid layui-word-aux">%</div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">当前加权分红</label>
                    <div class="layui-input-inline">
                        <input type="text" class="layui-input" readonly
                               value="{:cache('system')['joint_bonus_tp_2'] * 100}"/>
                    </div>
                    <div class="layui-form-mid layui-word-aux">%</div>
                </div>
                {if count($people) > 0 && $total * cache('system')['joint_bonus_tp'] > 0 }
                <div class="layui-form-item">
                    <label class="layui-form-label">分红预览</label>
                    <div class="layui-input-block">
                        <button type="button" class="layui-btn layui-btn-normal layui-btn-sm compute">点击计算</button>
                        <table id="demo" lay-filter="test"></table>
                    </div>
                </div>
                {/if}
            </form>

        </div>
    </div>
</div>
<div class="layui-form-item layui-layout-admin">
    <div class="layui-input-block">
        <div class="layui-footer" style="left: 0;">
            <button class="layui-btn" lay-filter="save" lay-submit formObj="#form">确认分红</button>
        </div>
    </div>
</div>
</body>
{include file="public/footer" /}
<script>
    layui.use(['table'], function () {
        var table = layui.table;
        $(".compute").click(function () {
            layerLoad();
            //第一个实例
            table.render({
                elem: '#demo'
                , url: '{:url("joint/getData")}' //数据接口
                , size: 'sm'
                , cols: [[ //表头
                    {field: 'nickname', title: '会员昵称', align: 'center'}
                    , {field: 'code', title: '会员编号', align: 'center'}
                    , {field: 'team_total_max', title: '团队业绩', align: 'center'}
                    , {field: 'average', title: '平均分配', align: 'center'}
                    , {field: 'weighting', title: '加权分红', align: 'center'}
                ]]
            });
            layer.closeAll();

        });

    });
</script>
</html>